package com.hippo.core.ui.compose.mine

import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.hippo.core.R
import com.hippo.core.ui.components.CommonDialog
import com.hippo.core.ui.components.InputEdit
import com.hippo.core.ui.components.ThemeButton
import com.hippo.core.ui.theme.HippoTheme

@Composable
fun ChangeNameDialog(onDismissRequest: () -> Unit, onSave: (String) -> Unit) {

    var name by remember { mutableStateOf("") }

    CommonDialog(
        title = stringResource(R.string.me_9),
        onDismissRequest = onDismissRequest,
    ) {

        Text(
            text = stringResource(R.string.me_10),
            modifier = Modifier.padding(top = 16.dp)
        )

        Spacer(modifier = Modifier.height(10.dp))

        InputEdit(
            text = name,
            hint = "",
            onValueChange = {
                name = it
            }
        )

        Spacer(modifier = Modifier.height(36.dp))

        ThemeButton(stringResource(R.string.save)) {
            onSave(name)
            onDismissRequest()
        }

    }

}



@Preview
@Composable
private fun ChangeNameDialogPreview() {
    HippoTheme {
        ChangeNameDialog(
            onDismissRequest = {},
            onSave = {},
        )
    }
}

